﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Model.MetadataTypes;
namespace Model.Entities
{
    /// <summary>
    /// 实体类 拓扑图基本信息表, 此类请勿动，以方便表字段更改时重新生成覆盖
    /// </summary>
    [Serializable]
    [MetadataType(typeof(HRDS_NET_TOPOLOGY_Metadata))]
    public partial class HRDS_NET_TOPOLOGY
    {
        /// <summary>
        /// 创建<see cref="HRDS_NET_TOPOLOGY"/>的实例
        /// </summary>
        public HRDS_NET_TOPOLOGY()
        {
                _hrds_rundatastatisticsCollection = new List<HRDS_RUNDATASTATISTICS>();
		                        _rbmt_stations_factionCollection = new List<RBMT_STATIONS_FACTION>();
		                }
        /// <summary>
        /// 站点网络编号【主键】
        /// </summary>
        public virtual string GRIDDINGNETID { get; set; }

        		
        /// <summary>
        /// 站点编号【外键：RMBT_FACILITY(MFID)】
        /// </summary>
        public virtual string MFID { get; set; }

    		
        /// <summary>
        /// 名称
        /// </summary>
        public virtual string NAME { get; set; }

    		
        /// <summary>
        /// 地址
        /// </summary>
        public virtual string ADDRESS { get; set; }

    		
        /// <summary>
        /// 站点类型CODE_TOPOTYPE（CODE_ID）（01：控制中心，02：汇聚节点，03：传感器）
        /// </summary>
        public virtual string TOPOLOGYTYPE { get; set; }

    		
        /// <summary>
        /// 经度（单位：度）
        /// </summary>
        public virtual decimal? LONGITUDE { get; set; }

    		
        /// <summary>
        /// 纬度（单位：度）
        /// </summary>
        public virtual decimal? LATITUDE { get; set; }

    		
        /// <summary>
        /// 备注
        /// </summary>
        public virtual string REMARK { get; set; }

    		
        /// <summary>
        /// 父站点网络编号编号
        /// </summary>
        public virtual string PARENTGRIDDINGNETID { get; set; }

    		
        /// <summary>
        /// 图片名称
        /// </summary>
        public virtual string DIAGRAM_NAME { get; set; }

    		
        /// <summary>
        /// 图片信息
        /// </summary>
        public virtual string DIAGRAM_XX { get; set; }

    		
        /// <summary>
        /// 汇聚节点的附属传感器【站点网络编号】
        /// </summary>
        public virtual string ATTACHSENSORID { get; set; }

    		
        /// <summary>
        /// 设备名字
        /// </summary>
        public virtual string EQNAMES { get; set; }

    		
        /// <summary>
        /// 设备ID
        /// </summary>
        public virtual string EQID { get; set; }

            private IList<HRDS_RUNDATASTATISTICS> _hrds_rundatastatisticsCollection;
        /// <summary>
        /// 所拥有的【运行数据统计表】的集合
        /// </summary>
        public virtual ReadOnlyCollection<HRDS_RUNDATASTATISTICS> HRDS_RUNDATASTATISTICSCollection { get; }

        /// <summary>
        /// 添加一个【运行数据统计表】
        /// </summary>
        /// <param name="hrds_rundatastatistics">要添加的【运行数据统计表】</param>
        /// <exception cref="ArgumentNullException"><paramref name="hrds_rundatastatistics"/>值为null。</exception>
        /// <exception cref="ArgumentException"><paramref name="hrds_rundatastatistics"/>已经被添加到某个<see cref="HRDS_NET_TOPOLOGY"/>当中。</exception>
        public virtual void AddHRDS_RUNDATASTATISTICS(HRDS_RUNDATASTATISTICS hrds_rundatastatistics)
        {
            if (hrds_rundatastatistics == null)
            {
                throw new ArgumentNullException("hrds_rundatastatistics");
            }
            if(hrds_rundatastatistics.HRDS_NET_TOPOLOGY != null)
            {
                throw new ArgumentException("hrds_rundatastatistics已被添加到某个HRDS_NET_TOPOLOGY当中，必须先从其中移除掉后才能添加到本实例中。", "hrds_rundatastatistics");
            }
            hrds_rundatastatistics.HRDS_NET_TOPOLOGY = this;
            _hrds_rundatastatisticsCollection.Add(hrds_rundatastatistics);
        }

        /// <summary>
        /// 移除一个【运行数据统计表】
        /// </summary>
        /// <param name="hrds_rundatastatistics">要移除的【运行数据统计表】</param>
        /// <returns>如果已成功移除<paramref name="hrds_rundatastatistics"/>，则为 true；否则为 false。 如果没有找到<paramref name="hrds_rundatastatistics"/>，该方法也会返回 false。</returns>
        /// <exception cref="ArgumentNullException"><paramref name="hrds_rundatastatistics"/>值为null。</exception>
        public virtual bool RemoveHRDS_RUNDATASTATISTICS(HRDS_RUNDATASTATISTICS hrds_rundatastatistics)
        {
            if (hrds_rundatastatistics == null)
            {
                throw new ArgumentNullException("hrds_rundatastatistics");
            }
            bool result = _hrds_rundatastatisticsCollection.Remove(hrds_rundatastatistics);
            if(result)
            {
                hrds_rundatastatistics.HRDS_NET_TOPOLOGY = null;
            }
            return result;
        }

        /// <summary>
        /// 清空【运行数据统计表】集合
        /// </summary>
        /// <returns>移除的【运行数据统计表】条数</returns>
		public virtual int ClearHRDS_RUNDATASTATISTICSCollection()
        {
            int count = _hrds_rundatastatisticsCollection.Count;
            foreach (var hrds_rundatastatistics in _hrds_rundatastatisticsCollection)
            {
                hrds_rundatastatistics.HRDS_NET_TOPOLOGY = null;
            }
            _hrds_rundatastatisticsCollection.Clear();
            return count;
        }

        private IList<RBMT_STATIONS_FACTION> _rbmt_stations_factionCollection;
        /// <summary>
        /// 所拥有的【站点功能说明】的集合
        /// </summary>
        public virtual ReadOnlyCollection<RBMT_STATIONS_FACTION> RBMT_STATIONS_FACTIONCollection { get; }

        /// <summary>
        /// 添加一个【站点功能说明】
        /// </summary>
        /// <param name="rbmt_stations_faction">要添加的【站点功能说明】</param>
        /// <exception cref="ArgumentNullException"><paramref name="rbmt_stations_faction"/>值为null。</exception>
        /// <exception cref="ArgumentException"><paramref name="rbmt_stations_faction"/>已经被添加到某个<see cref="HRDS_NET_TOPOLOGY"/>当中。</exception>
        public virtual void AddRBMT_STATIONS_FACTION(RBMT_STATIONS_FACTION rbmt_stations_faction)
        {
            if (rbmt_stations_faction == null)
            {
                throw new ArgumentNullException("rbmt_stations_faction");
            }
            if(rbmt_stations_faction.HRDS_NET_TOPOLOGY != null)
            {
                throw new ArgumentException("rbmt_stations_faction已被添加到某个HRDS_NET_TOPOLOGY当中，必须先从其中移除掉后才能添加到本实例中。", "rbmt_stations_faction");
            }
            rbmt_stations_faction.HRDS_NET_TOPOLOGY = this;
            _rbmt_stations_factionCollection.Add(rbmt_stations_faction);
        }

        /// <summary>
        /// 移除一个【站点功能说明】
        /// </summary>
        /// <param name="rbmt_stations_faction">要移除的【站点功能说明】</param>
        /// <returns>如果已成功移除<paramref name="rbmt_stations_faction"/>，则为 true；否则为 false。 如果没有找到<paramref name="rbmt_stations_faction"/>，该方法也会返回 false。</returns>
        /// <exception cref="ArgumentNullException"><paramref name="rbmt_stations_faction"/>值为null。</exception>
        public virtual bool RemoveRBMT_STATIONS_FACTION(RBMT_STATIONS_FACTION rbmt_stations_faction)
        {
            if (rbmt_stations_faction == null)
            {
                throw new ArgumentNullException("rbmt_stations_faction");
            }
            bool result = _rbmt_stations_factionCollection.Remove(rbmt_stations_faction);
            if(result)
            {
                rbmt_stations_faction.HRDS_NET_TOPOLOGY = null;
            }
            return result;
        }

        /// <summary>
        /// 清空【站点功能说明】集合
        /// </summary>
        /// <returns>移除的【站点功能说明】条数</returns>
		public virtual int ClearRBMT_STATIONS_FACTIONCollection()
        {
            int count = _rbmt_stations_factionCollection.Count;
            foreach (var rbmt_stations_faction in _rbmt_stations_factionCollection)
            {
                rbmt_stations_faction.HRDS_NET_TOPOLOGY = null;
            }
            _rbmt_stations_factionCollection.Clear();
            return count;
        }

		
        public override bool Equals(object obj)
        {
            HRDS_NET_TOPOLOGY model = obj as HRDS_NET_TOPOLOGY;
            return model != null && (ReferenceEquals(GRIDDINGNETID,null) ? ReferenceEquals(model.GRIDDINGNETID, null) : GRIDDINGNETID.Equals(model.GRIDDINGNETID));
        }
        public override int GetHashCode()
        {
            int hash = GetType().GetHashCode();
            hash = (hash * 397) ^ (ReferenceEquals(GRIDDINGNETID, null) ? 0 : GRIDDINGNETID.GetHashCode());
            return hash;
        }
    }
}
